<?php (defined('BASEPATH')) OR exit('No direct script access allowed');

class Home_Controller extends MY_Controller {
	public function __construct(){
		parent::__construct();
		if($this->config->item('public') == 'off'){
			redirect(base_url());
		}else{
			date_default_timezone_set('Asia/Ho_Chi_Minh');
			@ini_set( 'upload_max_size' , '1024M' );
			@ini_set( 'post_max_size', '1024M');
			@ini_set( 'max_execution_time', '0' );
			$data_ses=array(
				"current_language" => array('code' => 'vn'),
				"default_language" => array('code' => 'vn')
			);
			$this->session->set_userdata($data_ses);
			$pathSetting = APPPATH.'../assets/json/setting.json';
			if(file_exists($pathSetting)){
				$fileSetting = json_decode(file_get_contents($pathSetting), true);
			}else{
				$sql = 'SELECT * FROM tpt_setting';
				$fileSetting = $this->query($sql)->result_array();
			}
			foreach($fileSetting as $key => $value){
				if(!$this->session->userdata($key)){
					if($key != 'id'){
						$data_ses[$key] = $value;
						$this->session->set_userdata($data_ses);
					}
				}
			}
		}
	}
}